package dq.study.rmi;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

/**
 * @author dongqun
 * @version 1.0
 * @description 类的功能描述
 * @date 2019/9/26 10:07
 */
public class RmiServer extends UnicastRemoteObject implements IServer{


    protected RmiServer() throws RemoteException {
    }


    @Override
    public String hello(String msg) throws RemoteException {
        return "receive:" + msg;
    }

    @Override
    public Person getPerson(String name, String sex) throws RemoteException {
        return new Person(name,sex);
    }


    public static void main(String[] args) throws RemoteException, AlreadyBoundException, MalformedURLException {
        Registry registry = LocateRegistry.createRegistry(1099);
        IServer server = new RmiServer();
        registry.rebind("rmi://localhost:1099/myrmi", server);
//        Naming.bind("rmi://localhost:1099/myrmi", server);
    }
}
